
<!DOCTYPE html>
<html>
  <head>
    <title>Google Maps JavaScript API v3 Example: Map Geolocation</title>
    <meta name="viewport" content="initial-scale=1.0, user-scalable=no">
    <meta charset="UTF-8">
	
    <script type="text/javascript"  src="http://maps.googleapis.com/maps/api/js?sensor=true"></script>
	<script type="text/javascript" src="scripts/jquery.min.js"></script>
    <script type="text/javascript">
      var map;
      function initialize() {
        var myOptions = {
          zoom: 6,
          mapTypeId: google.maps.MapTypeId.ROADMAP
        };
        map = new google.maps.Map(document.getElementById('map_canvas'),
            myOptions);

        // Try HTML5 geolocation
        if(navigator.geolocation) {
          navigator.geolocation.getCurrentPosition(function(position) {
            var pos = new google.maps.LatLng(position.coords.latitude,
                                             position.coords.longitude);

            var infowindow = new google.maps.InfoWindow({
              map: map,
              position: pos,
              content: 'Location found using HTML5.'
            });

            map.setCenter(pos);
          }, function() {
            handleNoGeolocation(true);
          });
        } else {
          // Browser doesn't support Geolocation
          handleNoGeolocation(false);
        }
      }

      function handleNoGeolocation(errorFlag) {
        if (errorFlag) {
          var content = 'Error: The Geolocation service failed.';
        } else {
          var content = 'Error: Your browser doesn\'t support geolocation.';
        }
        var options = {
          map: map,
          position: new google.maps.LatLng(60, 105),
          content: content
        };

        var infowindow = new google.maps.InfoWindow(options);
        map.setCenter(options.position);
      }

     

	 function search(){
		var address="Hubei";
		var sensor=true;
		var search_str='address='+address+'&sensor='+sensor;
		var search_url='http://maps.google.com/maps/api/geocode/xml';
		/*
		$.ajax({
			url:search_url,
			type: 'GET',
			dataType:'xml',
			data:search_str,
			success:function(data){
				console(data);
			}
		});
		*/
		$.getJSON( search_url+'?'+search_str,function (data){
			alert(data);
		});
	}

	$('document').ready(function (){
		//alert('OK');
		 google.maps.event.addDomListener(window, 'load', initialize);

		 $('#search_btn').click(function(){
			search();
		 });
		
	});
    </script>

	<style>
		html, body {
		  height: 100%;
		  margin: 0;
		  padding: 0;
		}
		#map_canvas {
		  height: 100%;
		  width:70%;
		  float:left;
		}

		@media print {
		  html, body {
			height: auto;
		  }
		#map_search{
			width:20%;
		}	
	}
	</style>
  </head>
  <body>
    <div id="map_canvas" ></div>
	<div id="map_search">
		<div>

			<input type="text" name="search_item" id="search_item"/>
			<input type="button" value="Search" id="search_btn"/>
			<script type="text/javascript">
			<!--

			//-->

			</script>
		</div>
	</div>
  </body>
</html>

